package com.cxs.ocrrecognition.utils;

import ohos.app.Context;
import ohos.global.resource.NotExistException;
import ohos.global.resource.Resource;
import ohos.media.image.ImageSource;
import ohos.media.image.PixelMap;

import java.io.IOException;
import java.io.InputStream;

public class ImageUtil {
    public static PixelMap getPixelMap(Context context, int resourceId){
        try {
            InputStream inputStream = context.getResourceManager().getResource(resourceId);
            ImageSource imageSource = ImageSource.create(inputStream, null);
            PixelMap pixelmap = imageSource.createPixelmap(null);
            return pixelmap;
        } catch (IOException | NotExistException e) {

        }
        return null;
    }
}
